package com.itfreer.esb.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.esb.cilent.resultinfo.ResultInfo;
import com.itfreer.esb.param.EProxyType;
import com.itfreer.esb.proxy.IEsbGisProxy;
import com.itfreer.esb.proxy.IEsbProxy;

@Component
@Path("/esb/")
public class RestRegisterServer {
	@Autowired
	private IEsbProxy esbProxy;
	
	@Autowired
	private IEsbGisProxy esbGisProxy;
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@POST
	@Path("/register")
	@Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
	public List<Map<String,Object>> registerProxy() {
		ResultInfo arcgisInfo=esbProxy.registerProxy(EProxyType.Arcgis, "http://192.168.59.128:6080/arcgis/rest/services//hunan/hunanshi/MapServer", new Date());
		System.out.println("arcgis服务代理输出地址："+arcgisInfo.getContent());
		
		ResultInfo functionInfo=esbProxy.registerProxy(EProxyType.Function, "http://localhost:9090/esb/rest/esb/register", new Date());
		System.out.println("功能服务服务代理输出地址："+functionInfo.getContent());
		
		functionInfo=esbProxy.registerProxy(EProxyType.Function, "http://localhost:9090/esb/rest/esb/registerget", new Date());
		System.out.println("功能服务服务代理输出地址："+functionInfo.getContent());
		
		ResultInfo tempInfo=esbGisProxy.registerTemp(EProxyType.Arcgis, "http://192.168.59.128:6080/arcgis/rest/services//hunan/hunanshi/MapServer","127.0.0.1", new Date());
		System.out.println("临时代理服务服务代理输出地址："+tempInfo.getContent());
		
		Map<String,Object> item=new HashMap<String,Object>();
		item.put("name", "嘻嘻");
		item.put("age", 10);
		
		List<Map<String,Object>> r=new ArrayList<Map<String,Object>>();
		r.add(item);
		return r;

	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@POST
	@Path("/registerget")
	@Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
	public List<Map<String,Object>> registerGetProxy() {
		Map<String,Object> item=new HashMap<String,Object>();
		item.put("name", "嘻嘻");
		item.put("age", 10);
		
		List<Map<String,Object>> r=new ArrayList<Map<String,Object>>();
		r.add(item);
		return r;

	}
}
